-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[video_player] Implements background playback functionality #9212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Thanks for the contribution! Please see https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins for the process to make a multi-package PR, so that our CI can run tests. |
Thanks for the link, I missed that! I might be missing something very obvious here, but I'm not sure how to update so that the remaining checks will complete. From what I understand it fails due to a cached version of
I can get the camera example to run locally, but only if I use direct dependencies instead of overridden dependencies. What's the best approach here? Should I just remove the path-based dependencies for the camera example or is there another way to resolve it? |
@stuartmorgan-g It looks like
@ArvidNy You should be able to fix this by manually adding the rest of the dependencies to the failing plugins. They should look like: dependency_overrides:
video_player: {path: ../../../../packages/video_player/video_player}
video_player_android: {path: ../../../../packages/video_player/video_player_android}
video_player_avfoundation: {path: ../../../../packages/video_player/video_player_avfoundation}
video_player_platform_interface: {path: ../../../../packages/video_player/video_player_platform_interface}
video_player_web: {path: ../../../../packages/video_player/video_player_web} Let me know if that works. |
Yes, the tooling should account for that though.
That shouldn't have been necessary. What command did you run, exactly, to generate what's in the PR now? |
This is the command I ran: dart run script/tool/bin/flutter_plugin_tools.dart make-deps-path-based --target-dependencies=video_player_platform_interface,video_player_android,video_player_avfoundation,video_player,video_player_web |
Oh, and manually adding the rest of the dependency overrides does seem to resolve the issue, at least locally. So I can push that to resolve the PR tests if there's no other obvious fix for it. |
I figured you would want consistency in the code. On Android we don't always want to use wake lock so we need to know when the option is Lines 61 to 62 in cca0a59
I'm not sure that's better, but it allows for flexibility in case Apple would change anything in the future and we need to know when the option is set on another platform as well. That being said, I'm all for reducing the complexity of the PR if that's preferable. Is it better to only add the method to the Android implementation then and not the |
We want each implementation to be written in the way that makes sense for that implementation.
The Dart code and native code in question are part of the same package. There is no case where have the ability to change the native code in a package but not the Dart code in the same package, so I'm not sure what flexibility you are referring to.
Making a no-op implementation in Dart, avoiding unnecessary round trips to the host side, does not require removing the cross-platform abstraction. What the cross-platform abstraction should or shouldn't be is a separate question of behavior, not implementation. That's a question of what happens on other platforms. For instance, what is the expected behavior of |
Oh, you're right. I didn't think about that fact that the communication with the host side was unnecessary there and I didn't make that connection from your previous message – sorry about that. I've just removed the no-op on the native side for iOS and merged the latest changes from the PR you mentioned. For Android, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Web implementation (no-op that instantly returns) looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android overall looks good! Just left a nit and a question about a possibly required permission.
...r/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java
Show resolved
Hide resolved
...r/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java
Show resolved
Hide resolved
...r/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java
Show resolved
Hide resolved
This comment was marked as off-topic.
This comment was marked as off-topic.
@ArvidNy Are you still planning to address the remaining review feedback? |
Sure, I plan on resolving the feedback I got so this can be merged. I've been busy with other projects for the past months, but I hope I'll get around to it soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android changes LGTM! Thanks for the fixes.
I've now created a PR for only the platform interface package changes: #10054. I made the changes that the Gemini bot suggested if you want to review the new PR now. |
This pull request adds the missing implementation for background playback. This allows
video_player
to be used with e.g.audio_service
to continue playing audio after the screen is closed or the app is move to the background. A sample implementation for testing can be found here: https://github.com/ArvidNy/video_player_audio_serviceCloses flutter/flutter#62739
Pre-Review Checklist
[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3